package com.ruoyi.web.controller.wlsggk;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.waterdrop.wlsggk.pojo.TransferReplenish;
import com.waterdrop.wlsggk.service.ITransferReplenishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * wlsggkController
 *
 * @author Naruto
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/wlsggk/replenish")
public class TransferReplenishController extends BaseController {
    @Autowired
    private ITransferReplenishService transferReplenishService;

    /**
     * 查询wlsggk列表
     */
    @PreAuthorize("@ss.hasPermi('wlsggk:replenish:list')")
    @GetMapping("/list")
    public TableDataInfo list(TransferReplenish transferReplenish) {
        startPage();
        List<TransferReplenish> list = transferReplenishService.selectTransferReplenishList(transferReplenish);
        return getDataTable(list);
    }

    /**
     * 导出wlsggk列表
     */
    @PreAuthorize("@ss.hasPermi('wlsggk:replenish:export')")
    @Log(title = "wlsggk", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TransferReplenish transferReplenish) {
        List<TransferReplenish> list = transferReplenishService.selectTransferReplenishList(transferReplenish);
        ExcelUtil<TransferReplenish> util = new ExcelUtil<TransferReplenish>(TransferReplenish.class);
        util.exportExcel(response, list, "wlsggk数据");
    }

    /**
     * 获取wlsggk详细信息
     */
    @PreAuthorize("@ss.hasPermi('wlsggk:replenish:query')")
    @GetMapping(value = "/{replenishId}")
    public AjaxResult getInfo(@PathVariable("replenishId") Long replenishId) {
        return success(transferReplenishService.selectTransferReplenishByReplenishId(replenishId));
    }

    /**
     * 新增wlsggk
     */
    @PreAuthorize("@ss.hasPermi('wlsggk:replenish:add')")
    @Log(title = "wlsggk", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransferReplenish transferReplenish) {
        return toAjax(transferReplenishService.insertTransferReplenish(transferReplenish));
    }

    /**
     * 修改wlsggk
     */
    @PreAuthorize("@ss.hasPermi('wlsggk:replenish:edit')")
    @Log(title = "wlsggk", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransferReplenish transferReplenish) {
        return toAjax(transferReplenishService.updateTransferReplenish(transferReplenish));
    }

    /**
     * 删除wlsggk
     */
    @PreAuthorize("@ss.hasPermi('wlsggk:replenish:remove')")
    @Log(title = "wlsggk", businessType = BusinessType.DELETE)
    @DeleteMapping("/{replenishIds}")
    public AjaxResult remove(@PathVariable Long[] replenishIds) {
        return toAjax(transferReplenishService.deleteTransferReplenishByReplenishIds(replenishIds));
    }
}
